package printer.impl;

import java.util.Set;

import pojo.Customer;
import printer.DataPrinter;

public class DataPrinterImpl implements DataPrinter {

	public StringBuilder print(Set<Customer> customer, String format) {
		if("xml".equals(format)){
			StringBuilder stringBuilder=new StringBuilder();
			stringBuilder=stringBuilder.append("<Customers>"+"\n");
			for (Customer c:customer) {
				stringBuilder=stringBuilder.append("\t"+"<customer id="+c.getId()+">"+"\n");
				stringBuilder=stringBuilder.append("\t\t"+"<name>"+c.getName()+"</name>"+"\n");
				stringBuilder=stringBuilder.append("\t\t"+"<mail>"+c.getEmail()+"</mail>"+"\n");
				stringBuilder=stringBuilder.append("\t\t"+"<sex>"+c.getSex()+"</sex>"+"\n");
				stringBuilder=stringBuilder.append("\t\t"+"<birthday>"+c.getBirth()+"</birthday>"+"\n");
				stringBuilder=stringBuilder.append("\t"+"</customer>"+"\n");
			}
			stringBuilder=stringBuilder.append("</Customers>"+"\n");
			return stringBuilder;
		}
		else if("line".equals(format)){
			StringBuilder stringBuilder=new StringBuilder();
			for (Customer c:customer){
				stringBuilder=stringBuilder.append("ID:"+c.getId()+"   Name:"+c.getName()+"    Mail:"+c.getEmail()+
						"    Sex:"+c.getSex()+"    Birthday:"+c.getBirth()+"\n");
			}
			return stringBuilder;
		}
		return null;
	}
	
	

}
